# Maintainer: Jonas Witschel <diabonas@archlinux.org>
pkgname=tpm2-tss-engine
pkgver=1.1.0
pkgrel=2
pkgdesc='OpenSSL engine for Trusted Platform Module 2.0 devices'
arch=('loong64' 'x86_64')
url='https://github.com/tpm2-software/tpm2-tss-engine'
license=('BSD')
depends=('openssl' 'tpm2-tss' 'libtss2-esys.so' 'libtss2-mu.so' 'libtss2-tctildr.so')
checkdepends=('cmocka' 'expect' 'ibm-sw-tpm2' 'iproute2' 'tpm2-tools')
options=('debug')
source=("$url/releases/download/v$pkgver/$pkgname-$pkgver.tar.gz"{,.asc})
sha512sums=('5d2e08178be54350e8672245023d601a0d9d520f8c49e977af49d7c59b91d033c14b4a347b71e042fe7c5ff12af9fcc43b69fd1dc83a9f0db12d47d43e1107f4'
            'SKIP')
validpgpkeys=('D6B4D8BAC7E0CC97DCD4AC7272E88B53F7A95D84') # Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de>

prepare() {
	cd "$pkgname-$pkgver"
	sed -i 's/-Werror//' configure
	sed -i 's/unable to load Private Key/\0\\|failed loading private key/' test/failload.sh
}

build() {
	cd "$pkgname-$pkgver"
	./configure --prefix=/usr $( ((CHECKFUNC)) && echo --enable-unit --enable-integration)
	make
}

check() {
	cd "$pkgname-$pkgver"
	make check
}

package() {
	cd "$pkgname-$pkgver"
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
